package edu.hawaii.kukui

import edu.hawaii.kukui.KukuiRole

/**
 * User domain class.
 */
class KukuiUser {
  static transients = ['pass']
  static hasMany = [authorities: KukuiRole, activityTextAttempts: ActivityTextAttempt]
  static belongsTo = KukuiRole

  /** Username  */
  String username
  /** User Real Name */
  //String userRealName
  String userFirstName
  String userLastName
  /** MD5 Password  */
  String passwd
  /** enabled  */
  boolean enabled

  byte[] picture
  String building
  String floor

  String email
  boolean emailShow

  /** description  */
  String description = ''
  String toString() {
    "${userLastName}, ${userFirstName}"
  }

  /** plain password to create a MD5 password  */
  String pass = '[secret]'

  static constraints = {
    username(blank: false, unique: true)
    //userRealName(blank: false)
    picture(nullable:true, maxSize: 1048576 /* 1MB */)
    building(nullable: true)
    floor(nullable: true)
    passwd(blank: false)
    enabled()
  }
}
